<%@page import="transfer.OrderState"%>
<%@page import="java.util.ArrayList"%>
<%@page import="content.OrderContent"%>
<%@page import="controller.SessionAttribute"%>
<%@page import="transfer.User"%>
<%@page import="transfer.Order"%>
<%
session = request.getSession();
User user = (User) session.getAttribute(SessionAttribute.USER);
if (user != null) {
ArrayList list = OrderContent.getAllOrders(user);
%>

<h3>Your orders</h3>
<div class="box">
    <table class="table" rules=all>
        <tr>
            <td>#</td>
            <td>Creating date</td>
            <td>Sum</td>
            <td>State</td>
        </tr>
        <% for (int i = 0; i < list.size(); i++) {
            Order order = (Order) list.get(i);
            if (!order.getOrderState().equals(OrderState.ENTERING)) {
        %>
        <tr>
            <td><a href="index.jsp?content=conditionview&order=<%= order.getIdOrder() %>"><%= order.getIdOrder() %></a></td>
            <td><% if (order.getCreationDate() != null) out.print(order.getCreationDate()); %></td>
            <td><%= order.getTotalCost() %></td>
            <td><%= order.getOrderState().getNameOrderState() %></td>
        </tr>
        
        <%    
            }
        } 
        %>            
    </table>
</div>

<%
} else {
    %>
    <script> window.location.replace("index.jsp"); </script>
    <%
}
%>

